Skip to content

fix: accept GitHub URLs in settings add project#1110

Merged
leex279 merged 1 commit intocoleam00:devfrom
LocNguyenSGU:fix/issue-1108-settings-add-project-url-support
Apr 16, 2026
Merged

fix: accept GitHub URLs in settings add project#1110
leex279 merged 1 commit intocoleam00:devfrom
LocNguyenSGU:fix/issue-1108-settings-add-project-url-support

Conversation

@LocNguyenSGU
Copy link
Copy Markdown
Contributor

@LocNguyenSGU LocNguyenSGU commented Apr 12, 2026

Summary

Make the Settings page Add Project flow accept GitHub repository URLs the same way as the sidebar.

Reproduction

The server API supports either { url } or { path }, and the sidebar already classifies input accordingly. SettingsPage.tsx always submitted { path }, so entering a GitHub repository URL there behaved differently from the sidebar.

Patch Summary

  • add a shared getCodebaseInput() helper for path-vs-URL classification
  • reuse the helper in both the sidebar and Settings page
  • update the Settings placeholder to match the supported input types
  • add focused regression tests for URL/path classification

Risks

Low. The change only affects Add Project input classification and keeps existing local-path handling intact.

Validation

  • cd packages/web && bun test src/lib/codebase-input.test.ts

Summary by CodeRabbit

  • New Features

    • Add-project form accepts both repository URLs and local paths; input placeholder clarified to "GitHub URL or local path".
  • Refactor

    • Centralized input classification for project entries and unified submission handling to remove duplicated detection logic.
  • Tests

    • Added tests covering many URL formats and diverse local path variants to validate classification.
  • Documentation

    • Updated Settings/Projects docs to describe the new Add Project input flow and accepted input types.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c5f4633e-ab25-4657-8773-628124f93173

📥 Commits

Reviewing files that changed from the base of the PR and between 433a835 and 9dd57b2.

📒 Files selected for processing (7)
  • packages/docs-web/src/content/docs/adapters/web.md
  • packages/web/src/components/layout/Sidebar.tsx
  • packages/web/src/lib/api.ts
  • packages/web/src/lib/codebase-input.test.ts
  • packages/web/src/lib/codebase-input.ts
  • packages/web/src/routes/ChatPage.tsx
  • packages/web/src/routes/SettingsPage.tsx
✅ Files skipped from review due to trivial changes (3)
  • packages/docs-web/src/content/docs/adapters/web.md
  • packages/web/src/lib/codebase-input.test.ts
  • packages/web/src/lib/codebase-input.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/web/src/lib/api.ts
  • packages/web/src/components/layout/Sidebar.tsx
  • packages/web/src/routes/SettingsPage.tsx
  • packages/web/src/routes/ChatPage.tsx

📝 Walkthrough

Walkthrough

Extracted path/URL detection into a reusable getCodebaseInput(value: string) utility returning { url } or { path }. Replaced duplicated inline detection in Sidebar, ChatPage, and SettingsPage; re-exported the helper from api.ts; added unit tests and docs describing the new Add Project input flow. (46 words)

Changes

Cohort / File(s) Summary
Codebase input utility
packages/web/src/lib/codebase-input.ts, packages/web/src/lib/api.ts
Add getCodebaseInput(value: string) that trims input and returns { url: trimmed } for remote-like prefixes (http(s)://, ssh://, git@, git://) or { path: trimmed } otherwise; re-exported from api.ts.
Tests
packages/web/src/lib/codebase-input.test.ts
New Bun test suite covering trimming, HTTP(S) GitHub URLs, git@ shorthand, ssh:///git:// variants, relative/absolute local paths, ~ home paths, Windows drive-letter and UNC paths.
UI components
packages/web/src/components/layout/Sidebar.tsx, packages/web/src/routes/ChatPage.tsx, packages/web/src/routes/SettingsPage.tsx
Removed inline path-vs-url detection; submit add-project inputs via getCodebaseInput(trimmed) to addCodebase(...). SettingsPage switched to a single addValue state and updated placeholders/handlers; existing loading/error/promise and selection flows retained.
Docs
packages/docs-web/src/content/docs/adapters/web.md
Documented the Add Project input flow (sidebar “+” / Settings → Projects) and clarified which inputs are treated as remote vs local.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 I hopped through paths and URLs with glee,
Trimmed the edges, asked what it could be,
Remote or rooted — a helper set free,
Tests gave a wink, the sidebar said "Wee!"
Code munches carrots; cheers from me. 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description provides a clear Summary, Reproduction, Patch Summary, Risks, and Validation, covering the core intent and validation approach. However, it omits most sections from the template (UX Journey, Architecture Diagram, Label Snapshot, Change Metadata, Linked Issue, Human Verification, Side Effects, Rollback Plan, and detailed Risks/Mitigations). Complete the PR description by adding Architecture Diagram, UX Journey sections, and Rollback Plan. Specify the linked GitHub issue (#1108 or #1110), provide more detailed Human Verification and Side Effects analysis, and explicitly address Backward Compatibility and Validation Evidence.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the main objective: enabling Settings page Add Project to accept GitHub URLs like the sidebar does.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/web/src/lib/api.ts`:
- Around line 24-26: The isLocalPath check currently only treats absolute-style
paths as local; update the condition in the isLocalPath assignment so relative
paths (trimmed.startsWith('./') and trimmed.startsWith('../')) and bare names
(no URL scheme) are classified as local. You can do this by either adding checks
for './' and '../' to the existing expression or by inverting the logic: detect
URLs with a URL-scheme regex (e.g. scheme://) and treat anything that does not
match that scheme pattern as local. Modify the isLocalPath calculation (using
trimmed) so the function still returns { path: trimmed } for those relative/bare
inputs and { url: trimmed } only when a proper URL scheme is detected.

In `@packages/web/src/lib/codebase-input.test.ts`:
- Around line 4-28: Add regression tests to getCodebaseInput to cover relative
and UNC local paths: add cases asserting that inputs like './repo', 'repo' (bare
relative), and '\\\\server\\share' (UNC path) are classified as paths (returning
{ path: '...' }). Update the test suite around the getCodebaseInput describe
block by adding new test(...) entries for these inputs so they fail if
local-path classification regresses; reference the getCodebaseInput function in
your changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 53f1224b-556e-4140-91d7-2260896e7284

📥 Commits

Reviewing files that changed from the base of the PR and between 536584d and 0878261.

📒 Files selected for processing (4)
  • packages/web/src/components/layout/Sidebar.tsx
  • packages/web/src/lib/api.ts
  • packages/web/src/lib/codebase-input.test.ts
  • packages/web/src/routes/SettingsPage.tsx

Comment thread packages/web/src/lib/api.ts Outdated
Comment thread packages/web/src/lib/codebase-input.test.ts
@leex279 leex279 self-assigned this Apr 16, 2026
@leex279
Copy link
Copy Markdown
Collaborator

leex279 commented Apr 16, 2026

Thanks for raising #1108 and putting up the initial fix, @LocNguyenSGU — the shared getCodebaseInput() helper plus the URL/path classification tests were the right starting point.

I just pushed 433a8353 to finalize the PR for merge. Summary of the follow-up changes:

Critical fixes

  • Migrated the third Add Project call site (packages/web/src/routes/ChatPage.tsx) to getCodebaseInput() — without this, GitHub URLs typed in the chat sidebar Add Project would still hit the path branch and fail at the server.

Structural improvements

  • Extracted getCodebaseInput() from api.ts into a dedicated packages/web/src/lib/codebase-input.ts module (keeps the transport layer focused on HTTP). api.ts re-exports the symbol so all existing import sites continue to work unchanged.
  • Renamed addPath / setAddPathaddValue / setAddValue in SettingsPage.tsx since the field now holds either a URL or a path (matches the naming already used in the sidebar).

Test coverage

  • Added regression tests for the SSH git@, ssh://, and git:// regex arms, plus a whitespace-trim test — these are distinct branches in the helper that weren't exercised before.

Docs

  • Updated packages/docs-web/src/content/docs/adapters/web.md to document the unified Add Project entry point (sidebar + Settings + chat), the URL prefix list, and the new Projects section in Settings.

Validation

  • bun run type-check, bun run lint, bun run format:check, and the helper unit tests (10/10) all pass.
  • E2E roundtrip against POST /api/codebases confirmed both {path} and {url} shapes are accepted and validation correctly rejects empty / both-set bodies.

One operational note before merge

Heuristic note worth flagging in the PR body: with this change, ambiguous inputs (e.g., GitHub shorthand owner/repo) now go to the path branch instead of the url branch. Both fail at the server (neither is a valid clone target nor a real local path), but the surfaced error message changes. Worth mentioning in the description so reviewers don't miss it.

Thanks again for the fix.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/web/src/routes/SettingsPage.tsx (1)

277-279: Minor: destructured allowEnvKeys shadows the component-scope state.

The mutation parameter allowEnvKeys on line 278 shadows the allowEnvKeys state declared at line 268. Behavior is correct (the mutate arg is used), but given the ESLint zero-tolerance policy this could be flagged by no-shadow/@typescript-eslint/no-shadow if enabled. Consider renaming the mutation parameter (e.g., allowEnvKeysOverride) for clarity.

♻️ Suggested rename
-    mutationFn: ({ value, allowEnvKeys }: { value: string; allowEnvKeys?: boolean }) =>
-      addCodebase({ ...getCodebaseInput(value), allowEnvKeys }),
+    mutationFn: ({ value, allowEnvKeys: allow }: { value: string; allowEnvKeys?: boolean }) =>
+      addCodebase({ ...getCodebaseInput(value), allowEnvKeys: allow }),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/web/src/routes/SettingsPage.tsx` around lines 277 - 279, The
mutation parameter name allowEnvKeys in the addMutation useMutation call shadows
the component-scoped allowEnvKeys state; rename the parameter (e.g.,
allowEnvKeysOverride) in the mutationFn signature and update its usage where
calling addCodebase({ ...getCodebaseInput(value), allowEnvKeys }) to use the new
name (allowEnvKeysOverride) so the component state and mutation argument are
unambiguous; ensure references to addMutation and getCodebaseInput are updated
accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/web/src/routes/SettingsPage.tsx`:
- Around line 277-279: The mutation parameter name allowEnvKeys in the
addMutation useMutation call shadows the component-scoped allowEnvKeys state;
rename the parameter (e.g., allowEnvKeysOverride) in the mutationFn signature
and update its usage where calling addCodebase({ ...getCodebaseInput(value),
allowEnvKeys }) to use the new name (allowEnvKeysOverride) so the component
state and mutation argument are unambiguous; ensure references to addMutation
and getCodebaseInput are updated accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d489bee2-c405-4110-b598-2bd28b5a9ba7

📥 Commits

Reviewing files that changed from the base of the PR and between 00c0270 and 433a835.

📒 Files selected for processing (6)
  • packages/docs-web/src/content/docs/adapters/web.md
  • packages/web/src/lib/api.ts
  • packages/web/src/lib/codebase-input.test.ts
  • packages/web/src/lib/codebase-input.ts
  • packages/web/src/routes/ChatPage.tsx
  • packages/web/src/routes/SettingsPage.tsx
✅ Files skipped from review due to trivial changes (1)
  • packages/web/src/lib/codebase-input.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/web/src/lib/api.ts

…oints

Settings → Projects Add Project only submitted { path }, so GitHub URLs
entered there failed even though the API and the Sidebar Add Project
already accepted them. Closes coleam00#1108.

Changes:
- Add packages/web/src/lib/codebase-input.ts: shared getCodebaseInput()
  helper returning a discriminated { path } | { url } union (re-exported
  from api.ts for convenience).
- Use the helper from all three Add Project entry points: Sidebar,
  Settings, and ChatPage. Removes three divergent inline heuristics.
- SettingsPage: rename addPath → addValue (state now holds either URL
  or local path) and update placeholder text.
- Tests: cover https://, git@ shorthand, ssh://, git://, whitespace,
  unix/relative/home/Windows/UNC paths.
- Docs: document the unified Add Project entry point in adapters/web.md.

Heuristic flips from "assume URL unless explicitly local" to "assume
local unless explicitly remote" — only inputs starting with https?://,
ssh://, git@, or git:// are sent as { url }; everything else is sent
as { path }. The server already resolves tilde/relative paths.

Co-authored-by: Nguyen Huu Loc <lockbkbang@gmail.com>
@leex279 leex279 force-pushed the fix/issue-1108-settings-add-project-url-support branch from 433a835 to 9dd57b2 Compare April 16, 2026 21:43
@leex279
Copy link
Copy Markdown
Collaborator

leex279 commented Apr 16, 2026

Rebased onto current dev to resolve the conflicts (dev moved ahead with #1135 / #1195 / #1262 / #1263 since this PR was opened, and the env-keys consent code that the original commits modified has been removed from dev).

Because the conflicts touched logic that no longer exists on dev, a literal three-commit replay was producing more noise than signal. I squashed the three previous commits (0878261, 00c0270, 433a835) into a single commit 9dd57b2f applied directly on top of current dev. @LocNguyenSGU is preserved as Co-authored-by so commit authorship is kept intact.

The end state is unchanged from what was reviewed:

  • Shared getCodebaseInput() helper in packages/web/src/lib/codebase-input.ts, re-exported from api.ts
  • All three Add Project entry points (Sidebar, Settings, ChatPage) use the helper
  • 10 unit tests covering https://, git@, ssh://, git://, whitespace, unix/relative/home/Windows/UNC paths
  • Settings state renamed addPathaddValue, placeholder updated
  • adapters/web.md documents the unified Add Project entry point

Validation re-run after rebase: bun run type-check (all 9 packages) ✓, bun run format:check ✓, helper tests 10/10 ✓. The repo-wide bun run lint shows 168 pre-existing errors on dev (in providers, workflows, server) that are unrelated to this PR — lint-staged ran clean on the changed files at commit time.

mergeable: MERGEABLE. Ready for final review.

@leex279
Copy link
Copy Markdown
Collaborator

leex279 commented Apr 16, 2026

The failing check (test (windows-latest) → "Check bundled defaults") is not from this PR. It's a pre-existing regression on dev introduced by #1263.

Filed as #1265 with reproduction steps, root cause, and three suggested fixes. The same step fails on dev's own commit 86e4c8d (CI run) and on every PR rebased onto current dev. Linux CI passes both on dev and on this PR.

This PR remains ready to merge once #1265 is resolved (or the Windows check is treated as a known-failing pre-existing issue and not a blocker).

@leex279 leex279 merged commit b7b445b into coleam00:dev Apr 16, 2026
3 of 4 checks passed
joaobmonteiro pushed a commit to joaobmonteiro/Archon that referenced this pull request Apr 26, 2026
…tings-add-project-url-support

fix: accept GitHub URLs in settings add project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants